//
//  CompleteViewController.m
//  LineMoney
//
//  Created by 尹宁 on 16/7/12.
//  Copyright © 2016年 范琦. All rights reserved.
//

#import "CompleteViewController.h"
#import "CompleteTableViewCell.h"
@interface CompleteViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *listArr;
@property (nonatomic, strong) UIView *thingView;
@property (nonatomic, strong) UIButton *myBidButton;  // 招标
@property (nonatomic, strong) UIButton *myTenderButton; // 投标
@property (nonatomic, strong) UIView *haveThingView; // 下方随着变动的横条
@end

@implementation CompleteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"已完成";
    [self creatSegment];
    [self initTableView];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
}

- (void)creatSegment
{
    if (_thingView == nil) {
        
        _thingView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, 40)];
        _thingView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_thingView];
        
        _myBidButton = [UIButton buttonWithType:UIButtonTypeSystem];
        _myBidButton.frame = CGRectMake(_thingView.bounds.size.width / 4, 5, KSCREENWIDTH / 5, 30);
        [_myBidButton setTitle:@"我的投标" forState:UIControlStateNormal];
        [_thingView addSubview:_myBidButton];
        
        _myTenderButton = [UIButton buttonWithType:UIButtonTypeSystem];
        _myTenderButton.frame = CGRectMake(_thingView.bounds.size.width / 2 +(KSCREENWIDTH / 2 - _myBidButton.frame.origin.x - _myBidButton.bounds.size.width), 5, KSCREENWIDTH / 5, 30);
        [_myTenderButton setTitle:@"我的招标" forState:UIControlStateNormal];
        [_thingView addSubview:_myTenderButton];
        
        [_myBidButton addTarget:self action:@selector(haveThing) forControlEvents:UIControlEventTouchUpInside];
        [_myTenderButton addTarget:self action:@selector(helpThing) forControlEvents:UIControlEventTouchUpInside];
        
        // 上下方的2条线
//        top = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, 0.5)];
//        top.backgroundColor = [UIColor lightGrayColor];
//        top.alpha = 0.3;
//        [_thingView addSubview:top];
//        
//        bottom = [[UIView alloc] initWithFrame:CGRectMake(0, _thingView.bounds.size.height - 1, KSCREENWIDTH, 0.5)];
//        bottom.backgroundColor = [UIColor lightGrayColor];
//        bottom.alpha = 0.3;
//        [_thingView addSubview:bottom];
        
        
        // 下方横条
        _haveThingView = [[UIView alloc]initWithFrame:CGRectMake(_myBidButton.frame.origin.x + 10, _thingView.bounds.size.height - 3, _myBidButton.bounds.size.width - 20, 1)];
        _haveThingView.backgroundColor = BACKGROUNDCOLOR;
        [_thingView addSubview:_haveThingView];
        
        _myBidButton.tintColor = BACKGROUNDCOLOR;
        _myTenderButton.tintColor = [UIColor blackColor];
        _myBidButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _myTenderButton.titleLabel.font = [UIFont systemFontOfSize:14];
        
    }
    
}

// 我有事触发方法
- (void)haveThing
{
    _myBidButton.tintColor = BACKGROUNDCOLOR;
    _myTenderButton.tintColor = [UIColor blackColor];
    //    [self listNetHandle:@"/My/myWys.html"];
//    [self setupRefresh];
    [UIView animateWithDuration:0.15 animations:^{
        _haveThingView.frame = CGRectMake(_myBidButton.frame.origin.x + 10, _thingView.bounds.size.height - 3, _myBidButton.bounds.size.width - 20, 1);
    }];
    
}
// 我帮事触发方法
- (void)helpThing
{

    _myBidButton.tintColor = [UIColor blackColor];
    _myTenderButton.tintColor = BACKGROUNDCOLOR;
    //    [self listNetHandle:@"/My/myWbs.html"];
//    [self setupRefresh];
    
    [UIView animateWithDuration:0.15 animations:^{
        _haveThingView.frame = CGRectMake(_myTenderButton.frame.origin.x + 10, _thingView.bounds.size.height - 3, _myTenderButton.bounds.size.width - 20, 1);
    }];
}

- (void)initTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, _thingView.bounds.size.height, KSCREENWIDTH, KSCREENHEIGHT - _thingView.bounds.size.height) style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    _tableView.rowHeight = KSCREENHEIGHT / 6.3;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];// 如果没有数据下方不显示分割线
    [_tableView registerNib:[UINib nibWithNibName:@"CompleteTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CompleteTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];// 去掉点击之后的阴影
    cell.MoreImage.hidden = YES;
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 126;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
